<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>后台管理 - 易买网</title>
<link type="text/css" rel="stylesheet" href="css/style.css" />
<script type="text/javascript" src="scripts/function-manage.js"></script>
</head>
<body>
<div id="header" class="wrap">
	<div id="logo"><img src="../images/logo.gif" /></div>
	<div class="help"><a href="../index.jsp">返回前台页面</a></div>
	<div class="navbar">
		<ul class="clearfix">
			<li><a href="index.jsp">首页</a></li>
			<li><a href="user.jsp">用户</a></li>
			<li class="current"><a href="productList">商品</a></li>
			<li><a href="order.jsp">订单</a></li>
			<li><a href="selectMessage">留言</a></li>
			<li><a href="selectNews">新闻</a></li>
		</ul>
	</div>
</div>
<div id="childNav">
	<div class="welcome wrap">
		管理员pillys您好，今天是2012-12-21，欢迎回到管理后台。
	</div>
</div>
<div id="position" class="wrap">
	您现在的位置：<a href="index.jsp">易买网</a> &gt; 管理后台
</div>
<div id="main" class="wrap">
	<div id="menu-mng" class="lefter">
		<div class="box">
			<dl>
				<dt>用户管理</dt>
				<dd><em><a href="user-add.jsp">新增</a></em><a href="user.jsp">用户管理</a></dd>
				<dt>商品信息</dt>
				<dd><em><a href="addProduct">新增</a></em><a href="list">分类管理</a></dd>
				<dd><em><a href="add.do">新增</a></em><a href="productList">商品管理</a></dd>
				<dt>订单管理</dt>
				<dd><a href="order.jsp">订单管理</a></dd>
				<dt>留言管理</dt>
				<dd><a href="selectMessage">留言管理</a></dd>
				<dt>新闻管理</dt>
				<dd><em><a href="addNews">新增</a></em><a href="selectNews">新闻管理</a></dd>
			</dl>
		</div>
	</div>
	<div class="main">
		<h2>商品管理</h2>
		<div>
			<form action="select.do">
				<select name="classId">
					<option value=0>所属分类</option>
					<c:forEach var="productClass" items="${productClasses }">
						<option value="${productClass.classId }">${productClass.className }</option>
					</c:forEach>
				</select>
				商品名称：<input type="text" name="productName" value="${productName }"><input type="submit" value="查询">
			</form>
		</div>
		<div class="manage">
			<table class="list">
				<tr>
					<th>ID</th>
					<th>商品名称</th>
					<th>操作</th>
				</tr>
				<c:choose>
					<c:when test="${pager != null && fn:length(pager.datas) > 0 }">
						<c:forEach var="product" items="${pager.datas }">
								<tr>
									<td class="first w4 c">${product.productId }</td>
									<td class="thumb"><img src="images/product/${product.productImg }" /><a href="../product-view.jsp" target="_blank">${product.productName }</a></td>
									<td class="w1 c"><a href="update.do?productId=${product.productId }">修改</a> 
													<a onclick="return confirm('确定要删除吗?')" href="delete.do?productId=${product.productId }&pageIndex=${pager.pageIndex }" >删除</a></td>
								</tr>
						</c:forEach>
					</c:when>
					<c:otherwise>
							<tr><td colspan="3">暂无数据</td></tr>
					</c:otherwise>
				</c:choose>
				<tr>
					<td class="first w4 c" colspan="3" align="center">
						<c:if test="${pager.pageIndex>1 }">
						<a href="productList.do?pageIndex=1">首页</a> 
						<a href="productList.do?pageIndex=${pager.pageIndex-1 }">上一页</a> 
						</c:if>
						<c:forEach var="pn" begin="${pager.start }" end="${pager.end }">
							<c:if test="${pn != pager.pageIndex }">
								<a href="productList.do?pageIndex=${pn }">${pn }</a>&nbsp
							</c:if>
							<c:if test="${pn == pager.pageIndex }">
								${pn }&nbsp
							</c:if>
						</c:forEach> 
						<c:if test="${pager.pageIndex<pager.totalPage }">
						<a href="productList.do?pageIndex=${pager.pageIndex+1 }">下一页</a> 
						<a href="productList.do?pageIndex=${pager.totalPage }">末页</a>
						</c:if>
					</td>
				</tr>
			</table>
		</div>
	</div>
	<div class="clear"></div>
</div>
<div id="footer">
	Copyright &copy; 2017 爱苗科技 All Rights Reserved. 皖ICP证000001号
</div>
</body>
</html>